package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.news.NewsExpertSection;
import com.ruoyi.system.domain.news.query.NewsExpertSectionQuery;
import com.ruoyi.system.domain.news.vo.NewsExpertSectionVo;
import com.ruoyi.system.domain.news.vo.NewsExpertSectionVo;
import com.ruoyi.system.mapper.news.NewsExpertSectionMapper;
import com.ruoyi.system.service.news.NewsExpertSectionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsExpertSectionServiceImpl extends ServiceImpl<NewsExpertSectionMapper, NewsExpertSection>
        implements NewsExpertSectionService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsExpertSectionVo> getNewsExpertSectionList(NewsExpertSectionQuery newsExpertSectionQuery) {
        if (newsExpertSectionQuery.getIfPage()) {
            PageHelper.startPage(newsExpertSectionQuery.getPageNum(), newsExpertSectionQuery.getPageSize());
        }
        List<NewsExpertSectionVo> newsExpertSectionVoList = baseMapper.getNewsExpertSectionList(newsExpertSectionQuery);
        if (!newsExpertSectionVoList.isEmpty() && newsExpertSectionQuery.getId() == null) {
            for (NewsExpertSectionVo newsExpertSectionVo:newsExpertSectionVoList) {
                newsExpertSectionVo.setContent(null);
            }
        }
        return newsExpertSectionVoList;
    }
}
